<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>鼠标悬停更换图片</title>
    <link rel="stylesheet" href="base.css">
    <style>
        li{
            float: left;
            margin-top: 20px;
            margin-left: 10px;
            border: 5px solid #fff;
        }
        .active{
            border: 5px solid red;
            
        }
        #bigpicture{
            margin-left: 143px;
        }
    </style>
</head>
<body>
    <img id="bigpicture" src="img/brand_goods_1.jpg" alt="" width="400">
    <ul>
        <li class="active"><a href="#">
            <img src="img/brand_goods_1.jpg" class="smallImg" width="150px" alt="">
        </a></li>
        <li><a href="#">
            <img src="img/brand_goods_2.jpg" class="smallImg" width="150px" alt="">
        </a></li>
        <li><a href="#">
            <img src="img/brand_goods_3.jpg" class="smallImg" width="150px" alt="">
        </a></li>
        <li><a href="#">
            <img src="img/brand_goods_4.jpg" class="smallImg" width="150px" alt="">
        </a></li>
    </ul>
    <script>
        var bigpicture = document.getElementById('bigpicture');
        var smallImg = document.getElementsByClassName('smallImg');
        for(var i = 0; i < smallImg.length ; i++){
            smallImg[i].onmouseover =function(){
                for(var j =0;j < smallImg.length;j++){
                    smallImg[j].parentNode.parentNode.setAttribute('class','')
                }
                this.parentNode.parentNode.setAttribute('class','active')
                var smallImgsrc = this.getAttribute('src');
                bigpicture.setAttribute('src',smallImgsrc);
            }
        }
        

    </script>
</body>
</html>